
var Class = require('ClassBuilder');

var crypters = require('./crypters.js');

var MessageParser = Class(function( _public ) {

    _public._construct = function( msgBuffer ) {
        this.msgBuffer = msgBuffer;
    };

    _public.parse = function() {

        var buffer = this.msgBuffer;

        var cryptionType = buffer[0];

        var crypt = crypters[ cryptionType ];

        return crypt? crypt( buffer.slice(1) ): new Buffer(0);
        
    };

});

module.exports = MessageParser;